﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace AnQinFrameWorkAPI.Entity.SystemCore.Entity;

/// <summary>
///     菜单表模型
/// </summary>
[Table("Menu")]
public class MenuModel
{
    #region 字段

    /// <summary>
    ///     菜单表id
    /// </summary>
    [Key]
    [MaxLength(36)]
    public Guid Id { get; set; }

    /// <summary>
    ///     菜单名称
    /// </summary>
    [MaxLength(50)]
    public string Name { get; set; }

    /// <summary>
    ///     菜单icon
    /// </summary>
    [MaxLength(250)]
    public string? Icon { get; set; }

    /// <summary>
    ///     上级菜单id
    /// </summary>
    [MaxLength(36)]
    public Guid? SuperiorId { get; set; }

    /// <summary>
    ///     是否渲染
    /// </summary>
    public bool IsShow { get; set; }

    /// <summary>
    ///     是否启用
    /// </summary>
    public bool IsEnable { get; set; }

    /// <summary>
    ///     是否开启缓存
    /// </summary>
    public bool IsCache { get; set; }

    /// <summary>
    ///     序号
    /// </summary>
    public int Order { get; set; }

    /// <summary>
    ///     菜单地址
    /// </summary>
    [MaxLength(50)]
    public string? Url { get; set; }

    /// <summary>
    ///     备注
    /// </summary>
    [Column(TypeName = "nvarchar(max)")]
    public string? Remark { get; set; }

    /// <summary>
    ///     创建时间
    /// </summary>
    public DateTime CreateTime { get; set; }

    #endregion

    #region 关联

    /// <summary>
    ///     菜单
    /// </summary>
    public virtual MenuModel Menu { get; set; }

    /// <summary>
    /// 下级菜单列表
    /// </summary>
    public virtual ICollection<MenuModel> Children { get; set; } = new List<MenuModel>();

    /// <summary>
    ///     菜单按钮列表
    /// </summary>
    public virtual ICollection<MenuButtonModel> MenuButtonList { get; set; } = new List<MenuButtonModel>();

    /// <summary>
    ///     菜单字段列表
    /// </summary>
    public virtual ICollection<MenuFieldModel> MenuFieldList { get; set; } = new List<MenuFieldModel>();

    #endregion
}